<?php
/**
 * Created by PhpStorm.
 * User: yuliang
 * Date: 2017/6/1
 * Time: 下午4:11
 */

namespace app\common\model;

use think\Db;
use think\Model;
class Course extends Model
{
    public function profile(){
        return $this->hasOne('Profile');
    }
    protected $table = 'jy_course';

    protected $autoWriteTimestamp = 'datetime';


    // 获取组合课程包含的子课程
    public function courseGroup($course_id){
        $course = Db::table('jy_course_group')->alias('a')->join('jy_course b','a.child_id = b.id','LEFT')
            ->field('b.id,b.title,b.subtitle,b.description,b.teacher_name,b.type,b.attachment,b.hour,b.img_url,b.price,b.offline_price')
            ->where("a.parent_id = $course_id")->select();
        return $course;
    }
}